import axios from '@/util/request.js'

export function findPermissionTree() {
    return axios.post("permission/findPermissionTree");
}

export function findPermissionTreeByUserId(userId) {
    return axios.post("permission/findPermissionTreeByUserId", userId, axios.textConfig);
}

export function findFlatPermissions() {
    return axios.post("permission/findAll");
}

export function saveOrUpdatePermission(data) {
    let path = !data.permissionId ? "save" : "update";
    return axios.post(`permission/${path}`, data);
}

export function deletePermission(permissionId) {
    return axios.post("permission/delete", permissionId, axios.textConfig);
}